package cn.haoxsf.app.common.util;

import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

import java.util.List;

/**
 * @program: app
 * @description: 校验工具
 * @author: Ele qvbanfm@qq.com
 * @create: 2020-01-07 09:04
 **/
public class ValidatedUtil {
    public static String getErrorMessage(BindingResult result){
        String str = null ;
        List<ObjectError> allErrors = result.getAllErrors();
        for (ObjectError error : allErrors){
            str = error.getDefaultMessage();
        }
        return str;
    }
}
